package com.lihepeng.leecode.design_patten.dynamic_proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {
    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始进入增强方法~~~");
        FunctionEnhanceTools functionEnhanceTools = new FunctionEnhanceTools();
        functionEnhanceTools.beforeLog(method.getName());
        Object invokeResult = method.invoke(target, args);
        functionEnhanceTools.afterLog(method.getName());
        return invokeResult;
    }
}
